Asssumes you have aready run: - config - workflow_deepseaNiN_Start
You now have the objects needed to explore the dataset and find the best way to apply biogeographic splits. This is a pre-step before running the workflow again on the split dataset to explore possible LKMs.
This requires exploring the dataset to theorise the best ways to split the data with: - environmental biplots/colourings
then applying the splits.
library(plotly)
library(readxl)
should include all env Vars and otus to explore, and make species richness variable
#add species data and sp richness variable
env_sub_meta1<-cbind(env,otu_6)
env_sub_meta1$spRich<-rowSums(otu_6[,-c(1:which(colnames(otu_6)=="Zoanthidae"))]!=0)
#rename X
env_sub_meta1$X <- env$X.y
env_sub_meta1 <-env_sub_meta1 %>% select (-c(X.y))
#add samplID
env_sub_meta1$SampID<-envSel$SampID
Note that biotopes were last assigned in march 2022 and therefore there are some addional samples that have not yet got a biotope assigned. These should just be NAs
biotopeInfo<-read_xlsx(file.path(dataPath, "inputs/MAREANO_provisional_biotope_classification_0322.xlsx"), sheet=1) %>%
select(-c(x_coordinate_UTM33N, y_coordinate_UTM33N))
env_sub_meta<-left_join(env_sub_meta1,biotopeInfo)
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
summary(env_sub_meta)
Tmean_Robinson salt_max Smax_Robinson swDensRob_avs BO22_icecoverltmax_ss
Min. :-1.067 Min. :34.81 Min. :34.43 Min. :1027 Min. :0.00000
1st Qu.: 4.544 1st Qu.:34.98 1st Qu.:35.01 1st Qu.:1028 1st Qu.:0.00000
Median : 6.563 Median :35.13 Median :35.13 Median :1029 Median :0.00000
Mean : 5.880 Mean :35.11 Mean :35.12 Mean :1029 Mean :0.02214
3rd Qu.: 7.303 3rd Qu.:35.19 3rd Qu.:35.31 3rd Qu.:1029 3rd Qu.:0.00000
Max. : 8.447 Max. :35.82 Max. :35.42 Max. :1031 Max. :0.92838
BO22_icecovermean_ss BO22_dissoxmean_bdmean BO22_ppltmin_ss X.y Y
Min. :0.000000 Min. :282.5 Min. :0.000e+00 Min. :-107939 Min. :6944134
1st Qu.:0.000000 1st Qu.:286.3 1st Qu.:0.000e+00 1st Qu.: 161061 1st Qu.:7310134
Median :0.000000 Median :293.3 Median :1.465e-05 Median : 472061 Median :7742034
Mean :0.007224 Mean :299.1 Mean :1.167e-04 Mean : 503105 Mean :7704256
3rd Qu.:0.000000 3rd Qu.:306.4 3rd Qu.:6.533e-05 3rd Qu.: 795711 3rd Qu.:8036584
Max. :0.409033 Max. :372.2 Max. :1.067e-03 Max. :1162261 Max. :8949734
spd_std CSpdsd_Robinson mud gravel BO22_silicateltmax_bdmean
Min. :0.02103 Min. :1.085e-05 Min. : 0.00 Min. : 0.0 Min. :4.585
1st Qu.:0.05728 1st Qu.:3.842e-03 1st Qu.: 7.00 1st Qu.: 1.5 1st Qu.:5.895
Median :0.06776 Median :7.374e-03 Median :24.00 Median :18.0 Median :6.244
Mean :0.07592 Mean :9.038e-03 Mean :26.99 Mean :21.3 Mean :6.292
3rd Qu.:0.08946 3rd Qu.:1.272e-02 3rd Qu.:35.00 3rd Qu.:35.0 3rd Qu.:6.529
Max. :0.18145 Max. :5.305e-02 Max. :96.00 Max. :65.0 Max. :9.201
bathy gnmds1 gnmds2 X
Min. :-701.79 Min. :-2.2304 Min. :-1.80909 Min. :-107939
1st Qu.:-353.88 1st Qu.:-0.4374 1st Qu.:-0.26894 1st Qu.: 161061
Median :-269.97 Median :-0.2373 Median :-0.06045 Median : 472061
Mean :-293.06 Mean : 0.0000 Mean : 0.00000 Mean : 503105
3rd Qu.:-199.75 3rd Qu.: 0.3848 3rd Qu.: 0.27439 3rd Qu.: 795711
Max. : -38.61 Max. : 1.8972 Max. : 1.94516 Max. :1162261
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Tmean_Robinson,
y = bathy)) +
theme_classic() +
geom_point(aes(colour = gnmds1),
size = 1) +
scale_colour_gradientn(limits = c(-2.3, 1.9),
colors=c('red','yellow','green'))+
ggtitle("Temp (mean Robinson) vs Bathy - coloured by gnmds r6 ax1")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1bathy_v_temp_nmds1.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Tmean_Robinson,
y = bathy)) +
theme_classic() +
geom_point(aes(colour = Smax_Robinson),
size = 1) +
scale_colour_gradientn(limits = c(34.43, 35.43),
colors=c('green','yellow','blue'))+
ggtitle("Temp (mean Robinson) vs Bathy - coloured by salinity")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1bathy_v_temp_salinityMax.png"),
device = "png",
dpi=300 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Tmean_Robinson,
y = bathy)) +
theme_classic() +
geom_point(aes(colour = X.y),
size = 1) +
scale_colour_gradientn(limits = c(-107939, 1162261),
colors=c('red','yellow','blue'))+
ggtitle("Temp (mean Robinson) vs Bathy - coloured by longitude")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1bathy_v_temp_longitude.png"),
device = "png",
dpi=300 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Tmean_Robinson,
y = bathy)) +
theme_classic() +
geom_point(aes(colour = Y),
size = 1) +
scale_colour_gradientn(limits = c(6944134, 8949734),
colors=c('red','yellow','blue'))+
ggtitle("Temp (mean Robinson) vs Bathy - coloured by latitude")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1bathy_v_temp_latitude.png"),
device = "png",
dpi=300 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Tmean_Robinson,
y = bathy)) +
theme_classic() +
geom_point(aes(colour = BO22_icecoverltmax_ss),
size = 1) +
scale_colour_gradientn(limits = c(0,0.93),
colors=c('grey','turquoise','blue'))+
ggtitle("Temp (mean Robinson) vs Bathy - coloured by ice cover LT max")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1bathy_v_temp_iceCovLTmax.png"),
device = "png",
dpi=300 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Smax_Robinson,
y = bathy)) +
theme_classic() +
geom_point(aes(colour = Tmean_Robinson),
size = 1) +
scale_colour_gradientn(limits = c(-1.1, 8.5),
colors=c('red','yellow','green'))+
ggtitle("Salinity (max Robinson) vs Bathy - coloured by av Temp (R)")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1bathy_v_salMax_temp.png"),
device = "png",
dpi=300 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Smax_Robinson,
y = Tmean_Robinson)) +
theme_classic() +
geom_point(aes(colour = gnmds1),
size = 1) +
scale_colour_gradientn(limits = c(-2, 2.5),
colors=c('red','yellow','green'))+
ggtitle("Temp (mean Robinson) vs Salinity (max R) - coloured by gnmds r6 ax 1 - grey 2.5-5")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1tempRmean_v_salinityRmax_nmds1.png"),
device = "png",
dpi=300 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Smax_Robinson,
y = Tmean_Robinson)) +
theme_classic() +
geom_point(aes(colour = BO22_dissoxmean_bdmean),
size = 1) +
scale_colour_gradientn(limits = c(282.5, 372.2),
colors=c('red','yellow','green'))+
ggtitle("Temp (mean Robinson) vs Salinity (max R) - coloured by dissolved oxygen")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1tempRmean_v_salinityRmax_disooxmean.png"),
device = "png",
dpi=300 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Smax_Robinson,
y = Tmean_Robinson)) +
theme_classic() +
geom_point(aes(colour = BO22_icecoverltmax_ss),
size = 1) +
scale_colour_gradientn(limits = c(0,0.93),
colors=c('blue','green','red'))+
ggtitle("Temp (AvR) v Salinity (maxR) - coloured by ice cover LT max")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1tempRmean_v_salinityRmax_iceCoveLTmax.png"),
device = "png",
dpi=800 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = X,
y = Y)) +
theme_classic() +
geom_point(aes(colour = Tmean_Robinson),
size = 1) +
scale_colour_gradientn(limits = c(-1.1, 8.5),
colors=c('blue','green','red'))+
ggtitle("Geography (X v Y) - coloured by mean temp")
ggplotly(tb_ax1)
NA
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_X_v_Y_tmeanR.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = swDensRob_avs),
size = 1) +
scale_colour_gradientn(limits = c(1027, 1031),
colors=c('blue','green','red'))+
ggtitle("Geography (X v Y) - coloured by water density")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_X_v_Y_swDenRobavs.png"),
device = "png",
dpi=800 )
Saving 7 x 7 in image
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = BO22_dissoxmean_bdmean),
size = 1) +
scale_colour_gradientn(limits = c(282,373),
colors=c('blue','green','red'))+
ggtitle("Geography (X v Y) - coloured by dissovled oxygen")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_X_v_Y_dissox.png"),
device = "png",
dpi=800 )
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = BO22_icecoverltmax_ss),
size = 1) +
scale_colour_gradientn(limits = c(0.00001,0.93),
colors=c('blue','green','red'))+
ggtitle("Geography (X v Y) - coloured by ice cover LT max - grey <0.00001")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_X_v_Y_iceCoveLTmax.png"),
device = "png",
dpi=800 )
Saving 7 x 7 in image
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Tmean_Robinson,
y = BO22_dissoxmean_bdmean)) +
theme_classic() +
geom_point(aes(colour = gnmds1),
size = 1) +
scale_colour_gradientn(limits = c(-2.3, 2),
colors=c('red','yellow','green'))+
ggtitle("Temp (mean Robinson) v disox mean - coloured by gnmds ax 1")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_TmeanR_v_dissoxltmin_gnmds1.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
tb_ax1<- ggplot(data = env_sub_meta,
aes(x = Tmean_Robinson,
y = BO22_dissoxmean_bdmean)) +
theme_classic() +
geom_point(aes(colour = bathy),
size = 1) +
scale_colour_gradientn(limits = c(-702, -38),
colors=c('red','yellow','green'))+
ggtitle("Temp (mean Robinson) v disox mean - coloured by bathymetry")
tb_ax1
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1TmeanR_v_dissoxltmin_bathy.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
dis_split <- ggplot(data = env,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = MLDmean_bathy),
size = 1) +
scale_colour_manual(values=cbPalette)+
# scale_colour_brewer(palette = "Set3") +
ggtitle("Easting vs Northing - coloured by Mixed layer depth proximity")
dis_split
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_XvY_MLDmeanBathy.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
env_sub_meta$ax1cat<-cut(env_sub_meta$gnmds1,
breaks=c(-3.2,-3,-2,-1,0,1,2,3,3.46))
env_sub_meta$ax2cat<-cut(env_sub_meta$gnmds2,
breaks=c(-1.9,-1,0,1,2,3,4,4.9))
dis_split <- ggplot(data = env_sub_meta,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = ax1cat),
size = 1) +
# scale_colour_manual(values=cbPalette) +# non-ordered colourblind pallette
scale_colour_brewer(palette = "Spectral") + # ordered colourblind pallette
ggtitle("Easting vs Northing - coloured by gnmds axis 1 HC units")
dis_split
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_XvY_ax1cat.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
env_sub_meta$temp5_1<-cut(env_sub_meta$Tmean_Robinson,
breaks=c(-1.1, 5.1, 8.5))
#
dis_split <- ggplot(data = env_sub_meta,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = temp5_1),
size = 1) +
# scale_colour_manual(values=cbPalette) +# non-ordered colourblind pallette
scale_colour_brewer(palette = "Set1") + # ordered colourblind pallette
ggtitle("Easting vs Northing - coloured by temp thresholded at 5.1*C")
dis_split
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_XvY_temp5_1.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
env_sub_meta$dissoxav305<-cut(env_sub_meta$BO22_dissoxmean_bdmean,
# breaks=c(256, 282, 360)) #ltmin
breaks=c(282.5,305,372.2),
labels=c("lowO2","hiO2")) #mean
#
dis_split <- ggplot(data = env_sub_meta,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = dissoxav305),
size = 1) +
# scale_colour_manual(values=cbPalette) +# non-ordered colourblind pallette
scale_colour_brewer(palette = "Set1") + # ordered colourblind pallette
ggtitle("Easting vs Northing - coloured by dissox av thresholded at 305")
dis_split
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_XvY_dissoxav305.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
env_sub_meta$iceMx_gt0<-cut(env_sub_meta$BO22_icecoverltmax_ss,
breaks=c(0, 0.00001, 0.92838))
#
dis_split <- ggplot(data = env_sub_meta,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = iceMx_gt0),
size = 1) +
# scale_colour_manual(values=cbPalette) +# non-ordered colourblind pallette
scale_colour_brewer(palette = "Set1") + # ordered colourblind pallette
ggtitle("Easting vs Northing - coloured by ice LT Max thresholded at >0")
dis_split
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_XvY_iceLTmx_gt0.png"),
device = "png",
dpi=300 )
dis_split <- ggplot(data = env_sub_meta,
aes(x = X.y,
y = Y)) +
theme_classic() +
geom_point(aes(colour = ax2cat),
size = 1) +
# scale_colour_manual(values=cbPalette) +# non-ordered colourblind pallette
scale_colour_brewer(palette = "Spectral") + # ordered colourblind pallette
ggtitle("Easting vs Northing - coloured by gnmds axis 2 HC units")
dis_split
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_XvY_ax2cat.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
t_gmo <- ggplot(data = env_sub_meta,
aes(x = gnmds1,
y = gnmds2)) +
theme_classic() +
coord_fixed() +
ggtitle("GNMDS coloured by temp 5.1 threshold",
subtitle = "First run") +
geom_point(aes(colour = factor(temp5_5))) +
geom_vline(xintercept = 0,
linetype = 2,
colour = "lightgray") +
geom_hline(yintercept = 0,
linetype = 2,
colour = "lightgray")+
guides(colour=guide_legend(ncol=2))
t_gmo
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_gnmds_temp5_1.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
o_gmo <- ggplot(data = env_sub_meta,
aes(x = gnmds1,
y = gnmds2)) +
theme_classic() +
coord_fixed() +
ggtitle("GNMDS coloured by dissox 305 threshold",
subtitle = "First run") +
geom_point(aes(colour = factor(dissox305))) +
geom_vline(xintercept = 0,
linetype = 2,
colour = "lightgray") +
geom_hline(yintercept = 0,
linetype = 2,
colour = "lightgray")+
guides(colour=guide_legend(ncol=2))
o_gmo
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_gnmds_dissox305.png"),
device = "png",
dpi=300 )
Saving 7 x 7 in image
i_gmo <- ggplot(data = env_sub_meta,
aes(x = gnmds1,
y = gnmds2)) +
theme_classic() +
coord_fixed() +
ggtitle("GNMDS coloured by ice max >0 threshold",
subtitle = "First run") +
geom_point(aes(colour = factor(iceMx_gt0))) +
geom_vline(xintercept = 0,
linetype = 2,
colour = "lightgray") +
geom_hline(yintercept = 0,
linetype = 2,
colour = "lightgray")+
guides(colour=guide_legend(ncol=2))
i_gmo
ggsave(filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_gnmds_iceMxgt0.png"),
device = "png",
dpi=300 )
comp<-i_gmo+o_gmo+t_gmo
##### Save some outputs
ggexport(comp,
filename = file.path(dataPath,"outputs/LoDensNoSB1031p1_gnmds_compare.png"),
width = 1500,
height = 500)
EDIT AREA FIRST!
save.image("I:/Scripts/deepseaNiN/Renv_deepseaNiN_LoDensNoSB1031p1.RData") # edit area first
There were 15 warnings (use warnings() to see them)
NOW CLEAR ENVIRONMENT BEFORE RUNNING FOR NEW AREA